<template>
	<view style="">
<!-- 		<u-navbar title="个人页面" @rightClick="rightClick" :autoBack="true">
		</u-navbar> -->

		<view class="top" :style="{'background-image': 'url('+settting+')' }">
			<image :src="user.picUrl">
			</image>
		</view>
		<list :loveList="loveList" :type="params.type" :shiwuType="shiwuType"></list>
	</view>
</template>

<script>
	import list from '../components/list.vue'
	export default {
		data() {
			return {
				timer: null,
				timer2: null,
				total:0,
				settting:"https://img.zcool.cn/community/03895a2576cbf480000012e7ecad562.gif",
				params: {
					pageSize: 6,
					pageNum: 1,
					userId: '',
					myId: ''
				},
				loveList: []
			}
		},
		onUnload() {
			console.log(123)
			if (this.timer2) {
				clearTimeout(this.timer2); // 清除定时器  
			}
		},
		onPullDownRefresh() {
			uni.showLoading({
				title: '加载中'
			});
			this.params.pageNum=1
			this.getList()
			this.timer = setTimeout(() => {
				uni.stopPullDownRefresh()
				uni.hideLoading();
			}, 1000)
		},
		onReachBottom() {
			this.getBottom()
		},
		methods: {
			async getBottom() {
				const that = this
				if (this.loveList.length < this.total) {
					this.params.pageNum++
					uni.showLoading({
						title: '加载中'
					});
					uni.request({
						url: that.$baseurl + "/font/getLoveByPersion",
						method: 'GET',
						data: that.params,
						success(res) {
							that.loveList = [...that.loveList, ...res.data.rows]
						}
					})
					uni.hideLoading();
				} else {
					this.$refs.uToast.show({
						type: 'default',
						title: '默认主题',
						message: "到底了...",
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/default.png'
					})
				}
			},
			async getList() {
				var user = uni.getStorageSync("loginUser")
				if (user !== null && user !== '' && user !== undefined) {
					this.params.myId = user.id
				}
				const res = await this.$myRuquest({
					url: '/font/getLoveByPersion',
					data: this.params
				})
				this.loveList = res.data.rows
				this.total = res.data.total
			},
			rightClick() {
				uni.navigateBack()
				console.log('rightClick');
			},
			leftClick() {
				uni.navigateBack()
				console.log('leftClick');
			},
		},
		onLoad(optins) {
			this.params.userId = optins.id
			this.getList()
		},
		components: {
			"list": list,
		},
	}
</script>

<style lang="scss" scoped>
	.top {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 420rpx;
		background-image: url("https://www.10wallpaper.com/wallpaper/1280x800/1702/Rem_re_zero_girl-2016_Anime_HD_Wallpaper_1280x800.jpg");
		background-size: cover;
		// filter: blur(5px);

		image {
			border-radius: 5px;
			margin-top: 405rpx;
			margin-left: 65%;
			width: 130rpx;
			height: 130rpx;
		}
	}
</style>